﻿using System;
using biz.ritter.javapi.xml;

namespace Nofs.Net.nofs.metadata.XMLDriver
{
    public sealed class XMLFolderDescription
    {
        private bool _canAdd;
        private bool _canRemove;
        private String _canAddMethod;
        private String _canRemoveMethod;
        private String _childTypeFilterMethod;

        public void ReadFromXML(Branch folderNode) // throws Exception 
        {
            _canAdd = Boolean.Parse(XMLHelper.TryReadChildContents(folderNode, "CanAdd", "false"));
            _canRemove = Boolean.Parse(XMLHelper.TryReadChildContents(folderNode, "CanRemove", "false"));
            _canAddMethod = XMLHelper.TryReadChildContents(folderNode, "CanAddMethod", "");
            _canRemoveMethod = XMLHelper.TryReadChildContents(folderNode, "CanRemoveMethod", "");
            _childTypeFilterMethod = XMLHelper.TryReadChildContents(folderNode, "ChildTypeFilterMethod", "");

        }

        public bool CanAdd() { return _canAdd; }
        public bool CanRemove() { return _canRemove; }
        public String CanAddMethod() { return _canAddMethod; }
        public String CanRemoveMethod() { return _canRemoveMethod; }
        public String ChildTypeFilterMethod() { return _childTypeFilterMethod; }
    }

}
